'use strict'
export function Tooltip (unit = null) {
  return {
    trigger: 'item',
    triggerOn: 'mousemove'
  }
}

/**
 * 数据部分
 * @param series { Array } [ 10, 20, 30, 40, 50, 60, 70]
 */
export function Series (data = [{ value: 10, name: 'A', children: [{ value: 10, name: 'A-A' }] }]) {
  function formatData (data) {
    data.forEach(item => {
      // 第一层球配色
      item.itemStyle = {
        color: {
          type: 'radial',
          x: 0.1,
          y: 0.5,
          r: 0.5,
          colorStops: [{
            offset: 0,
            color: '#B4EC51'
          }, {
            offset: 1,
            color: '#429321'
          }]
        }
      }
      item.lineStyle = {
        color: '#429321'
      }
      // 第二层球配色
      item.children.forEach(item_ => {
        item_.itemStyle = {
          color: {
            type: 'radial',
            x: 0.3,
            y: 0.4,
            r: 0.5,
            colorStops: [{
              offset: 0,
              color: '#1EA7FF'
            }, {
              offset: 1,
              color: '#002EFF'
            }]
          }
        }
        item_.lineStyle = {
          width: '1',
          size: '2',
          color: '#002EFF'
        }
      })
    })
    return data
  }

  console.log()
  return {
    type: 'tree',
    initialTreeDepth: 2,
    layout: 'radial',
    orient: 'LR',
    edgeShape: 'curve',
    data: formatData(data),
    symbolSize: 10,
    symbol: 'circle',
    roam: true,
    focusNodeAdjacency: true,
    itemStyle: {
      borderWidth: 1
    },
    label: {
      show: true,
      color: '#fff',
      fontSize: 10,
      fontFamily: 'SourceHanSansCN',
      position: 'inside',
      rotate: 0
    },
    lineStyle: {
      width: 1,
      curveness: 0
    }
  }
}
